package threaddemo;

public class TicketDemo extends Thread{
    private static int ticket =100;

    public TicketDemo() {
    }

    public TicketDemo(String name) {
        super(name);
    }

    @Override
    public void run() {
        while (true){
            if(ticket<=0)break;
            System.out.println(getName()+",正在买"+ticket+"张票");
            ticket--;
        }
    }
}
